package main

import (
	"fmt"
	"web-example/web"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

const (
	user     = "root"
	password = "ZCzc960830"
	host     = "127.0.0.1"
	port     = "3306"
	dbName   = "little_proj"
)

type User struct {
	Id   int
	Name string
	Pwd  string
}

func Test() {
	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", user, password, host, port, dbName)

	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})

	if err != nil {
		panic("failed to connect database")
	}

	user := User{}
	db.Take(&user)
	//db.Select()

	fmt.Printf("name:%s", user.Name)
}

func main() {
	web.StartWeb(":8080")
}
